﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TikTakTau_ClientProject
{
    public class TikTakTau_Client : iTikTakTau_ClientProject
    {
        /// <summary>
        /// Specifies the width of the galaxy.
        /// </summary>
        int tik;
        /// <summary>
        /// Specifies the height of the galaxy.
        /// </summary>
        int tak;
        /// <summary>
        /// Specifies the straight length of supply chain necessary to conquer the galaxy.
        /// </summary>
        int tau;
        /// <summary>
        /// Specifies whether the player represents the TikTaks (1) or TakTaus (2).
        /// </summary>
        int playerNumber;

        /// <summary>
        /// Warning. The default constructor is needed for this client to be loaded.
        /// </summary>
        public TikTakTau_Client()
        { }

        /// <summary>
        /// Sets up the client at the beginning of the game.
        /// </summary>
        /// <param name="_m"></param>
        /// <param name="_n"></param>
        /// <param name="_k"></param>
        /// <param name="_playerNumber"></param>
        /// <remarks>This method is called once at the beginning of a game.</remarks>
        public void setGameVariables(int _tik, int _tak, int _tau, int _playerNumber)
        {
            tik = _tik;
            tak = _tak;
            tau = _tau;
            playerNumber = _playerNumber;
        }

         public int[] playTurn(int[,] gameField, int turnNumber)
        {
            //put my player number into the first available place
            for (int i = 0; i < tik; i++)
            {
                for (int j = 0; j < tak; j++)
                {
                    //spot to check
                    int valueAtSpot = gameField[i, j];
                    if (valueAtSpot == 0)
                    {
                        return new int[] { i, j };
                    }
                }
            }
            //no available spots (game is probably a tie), so we shouldn't be here
            return new int[] { 0, 0 };
        }
    }
}
